<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get all information stored in an ID3 tag</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.id3-get-genre-name.html">id3_get_genre_name</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.id3-get-version.html">id3_get_version</a></div>
 <div class="up"><a href="ref.id3.html">ID3 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.id3-get-tag" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">id3_get_tag</h1>
  <p class="verinfo">(PECL id3 &gt;= 0.1)</p><p class="refpurpose"><span class="refname">id3_get_tag</span> &mdash; <span class="dc-title">Get all information stored in an ID3 tag</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.id3-get-tag-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>id3_get_tag</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$version</code><span class="initializer"> = ID3_BEST</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>id3_get_tag()</strong></span> is used to get all information stored
   in the id3 tag of the specified file.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.id3-get-tag-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">filename</code></em></dt>

     <dd>

      <p class="para">
       The path to the MP3 file
      </p>
      <p class="para">
       Instead of a filename you may also pass a valid stream resource
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">version</code></em></dt>

     <dd>

      <p class="para">
       Allows you to specify the version of the tag as MP3 files may contain
       both, version 1.x and version 2.x tags
      </p>
      <p class="para">
       Since version 0.2 <span class="function"><strong>id3_get_tag()</strong></span> also supports ID3
       tags of version 2.2, 2.3 and 2.4. To extract information from these
       tags, pass one of the constants ID3_V2_2, ID3_V2_3 or ID3_V2_4 as the
       second parameter.
       ID3 v2.x tags can contain a lot more information about the MP3 file
       than ID3 v1.x tags.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.id3-get-tag-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an associative array with various keys like: 
   <em>title</em>, <em>artist</em>, ..
  </p>
  <p class="para">
   The key <em>genre</em> will contain an integer between 0 and
   147. You may use <span class="function"><a href="function.id3-get-genre-name.html" class="function">id3_get_genre_name()</a></span> to convert it to
   a human readable string.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.id3-get-tag-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-569">
    <p><strong>Example #1 <span class="function"><strong>id3_get_tag()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$tag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">id3_get_tag</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"path/to/example.mp3"&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$tag</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [title] =&gt; DN-38416
    [artist] =&gt; Re:\Legion
    [album] =&gt; Reflections
    [year] =&gt; 2004
    [genre] =&gt; 19
)
</pre></div>
    </div>
   </div>
   <div class="example" id="example-570">
    <p><strong>Example #2 <span class="function"><strong>id3_get_tag()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$tag&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">id3_get_tag</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"path/to/example2.mp3"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ID3_V2_3&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$tag</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [copyright] =&gt; Dirty Mac
    [originalArtist] =&gt; Dirty Mac
    [composer] =&gt; Marcus Götze
    [artist] =&gt; Dirty Mac
    [title] =&gt; Little Big Man
    [album] =&gt; Demo-Tape
    [track] =&gt; 5/12
    [genre] =&gt; (17)Rock
    [year] =&gt; 2001
)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.id3-get-tag-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.id3-set-tag.html" class="function" rel="rdfs-seeAlso">id3_set_tag()</a> - Update information stored in an ID3 tag</span></li>
    <li class="member"><span class="function"><a href="function.id3-remove-tag.html" class="function" rel="rdfs-seeAlso">id3_remove_tag()</a> - Remove an existing ID3 tag</span></li>
    <li class="member"><span class="function"><a href="function.id3-get-version.html" class="function" rel="rdfs-seeAlso">id3_get_version()</a> - Get version of an ID3 tag</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.id3-get-genre-name.html">id3_get_genre_name</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.id3-get-version.html">id3_get_version</a></div>
 <div class="up"><a href="ref.id3.html">ID3 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
